import markdown



def md2html(md_file, html_file):
    with open(md_file, "r", encoding="utf-8") as file_md:
        md_text = file_md.read()

    exts = ['markdown.extensions.extra', 'markdown.extensions.codehilite','markdown.extensions.tables','markdown.extensions.toc']
    html = '''
    <html lang="zh-cn">
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="content-type" />
    <link href="css/default.css" rel="stylesheet">
    <link href="css/github.css" rel="stylesheet">
    </head>
    <body>
    %s
    </body>
    </html>
    '''
    ret = markdown.markdown(md_text, extensions=exts)
    html_text = html % ret
    with open(html_file, 'w', encoding="utf-8") as file_html:
        file_html.write(html_text)

    


if __name__ == '__main__':
    md_name = r"D:\code\note\md\decode.md"
    html_name = "d:/x/java.html"

    md2html(md_name, html_name)
